package cn.ynrcb.personnelfile.sysadmin.dao;

import cn.ynrcb.personnelfile.sysadmin.entity.SysRegionEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@Mapper
public interface SysRegionDao extends BaseMapper<SysRegionEntity>{
	/**
	 * 获取街道信息用于回显
	 * @param params
	 * @return
	 */
	List<Map<String, String>> getRegionList(@Param("map") Map<String, Object> params);

	@Select("select id,name,pid from sys_region where pid = #{pid}")
	List<SysRegionEntity> findByPid(String pid);

	@Select("select count(*) from sys_region where pid = #{pid}")
	int getCountByPId(String pid);

	@Select("select name from sys_region where id = #{id}")
	String getRegionNameByID(String id);

	/**
	 * 根据名称获取对应的地区编码
	 * @param name 地区名称
	 * @return 地区编码
	 */
	@Select("select id from sys_region where name = #{name}")
    String getIdByName(String name);


}
